package com.example.administrator.xxnapp.picture;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.transition.Slide;
import android.view.Gravity;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.example.administrator.xxnapp.BaseActivity;
import com.example.administrator.xxnapp.R;
import com.example.administrator.xxnapp.bean.PictureBean;

import butterknife.BindView;
import butterknife.ButterKnife;

public class PictureActivity extends BaseActivity {
    public static final String PICTURE_ANIMATION = "image";
    @BindView(R.id.act_picture_IV_Image)
    ImageView mIVImage;
    private PictureBean mPicture;

    @Override
    public void initView() {
        ButterKnife.bind(this);
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            Slide slide = new Slide(Gravity.BOTTOM);
            slide.addTarget(R.id.textView);
            getWindow().setEnterTransition(slide);
        }
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_picture;
    }

    @Override
    public void initBeforeDatas() {
        mImmersionBar.fitsSystemWindows(false)
                .transparentStatusBar().init();
        mPicture = (PictureBean) getIntent().getSerializableExtra(PICTURE_ANIMATION);
    }

    @Override
    public void setListeners() {
        RequestOptions options = new RequestOptions();
        options.centerCrop();
        Glide.with(this).load(mPicture.getPath()).apply(options)
                .transition(DrawableTransitionOptions.withCrossFade())
                .into(mIVImage);
    }
}
